package com.jty.lib_base.room.dao

import androidx.room.*
import com.jty.lib_base.room.bean.GridNoSubmit
import com.jty.lib_base.room.bean.GridPicture

@Dao
interface GridNoSubmitDao {
    @Query("SELECT * FROM GRID_NO_SUBMIT ORDER BY sort ASC")
    fun getAll(): List<GridNoSubmit>

    //@Query("SELECT * FROM GRID_NO_SUBMIT WHERE id = (:id) LIMIT 1")
    //fun queryById(id: Long): GridNoSubmit?

    @Query("SELECT * FROM GRID_NO_SUBMIT WHERE pageserial LIKE (:pageserial) LIMIT 1")
    fun queryByPageserial(pageserial: String): GridNoSubmit?

    @Query("SELECT MAX(sort) FROM GRID_NO_SUBMIT")
    fun getMaxSort(): Int

    @Insert
    fun insertAll(vararg gridNoSubmits: GridNoSubmit)

    @Insert(onConflict = OnConflictStrategy.REPLACE) //如果有相同的id就替换； ABORT默认这个，如果相同，会报错
    fun insertGridNoSubmit(vararg gridNoSubmits: GridNoSubmit)

    @Delete
    fun delete(gridNoSubmits: GridNoSubmit)

    @Delete
    fun deleteAll(vararg gridNoSubmits: GridNoSubmit)

    @Query("DELETE FROM GRID_NO_SUBMIT")
    fun deleteAll()


    @Update
    fun updateGridNoSubmit(vararg gridNoSubmits: GridNoSubmit)

}